{% extends 'base.html' %}
{% block body %}
<!--查询&删除方法-->
<div class="row">
    <div class="span10">
        <div>
            <h1 style="text-align:center">用户管理</h1><br/>
            <form action="/Organization/userQuery/" method="post">
                <input type="text" name="L_userQuery" style="margin-bottom:0;" required="required" placeholder="请输入您需要查询的信息">&nbsp;
                <button type="submit" style="margin-left: -4px;">查询</button>
            </form>
            <table class="table table-hover">
                <thead>
		            <tr>
			            <th style="width:10%;text-align:center">ID</th>
			            <th style="width:14%;text-align:center">姓名</th>
			            <th style="width:14%;text-align:center">用户名</th>
			            <th style="width:18%;text-align:center">邮箱</th>
			            <th style="width:14%;text-align:center">权限</th>
			            <th style="width:15%;text-align:center">选择</th>
			            <th style="width:15%;text-align:center">操作</th>
		            </tr>
	            </thead>
	            <tbody>
                    {% for u in L_userList %}
		                <tr>
			                <td style="padding-top:15px;text-align:center">{{ u.id }}</td>
			                <td style="padding-top:15px;text-align:center">{{ u.staffs.name }}</td>
			                <td style="padding-top:15px;text-align:center">{{ u.username }}</td>
			                <td style="padding-top:15px;text-align:center">{{ u.email }}</td>
			                <td style="padding-top:15px;text-align:center">
                                {% if u.roles.roleName != None %}
                                    {{ u.roles.roleName }}
                                {% endif %}
                            </td>
			                <td style="text-align:center">
                                <form style="margin-bottom:0px" action="/Organization/userUpdate/{{ u.id }}/" method="post" id="form{{ u.id }}">
                                    <select style="width: 100px;margin-bottom:0px" name="L_userUpdate" >
                                        <option value="1">普通用户</option>
                                        <option value="2">管理员</option>
                                    </select>
                                </form>
                            </td>
                            <td style="padding-top:12px;text-align:center"><a onclick="updateUser({{ u.id }})">修改</a>&nbsp;&nbsp;<a onclick="delUser({{ u.id }})">删除</a></td>
		                </tr>
                    {% endfor %}
	            </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
{% block script %}
    function delUser(id){
        d = confirm('确定删除此用户?');
        if (d){
            location.href = "http://localhost:8000/Organization/userRemove/"+id+'/';
        }
    }
    function updateUser(id){
        var s = document.getElementById('form'+id).submit()
    }
{% endblock %}
